package zl.osimall.front.controller;


import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import zl.osimall.common.bean.Category;
import zl.osimall.common.bean.Goods;
import zl.osimall.common.service.CategoryService;
import zl.osimall.common.service.GoodsService;

import java.util.List;

@Controller
public class IndexController {
    @Autowired
    private CategoryService categoryService;
    @Autowired
    private GoodsService goodsService;

    @GetMapping({"/index","/",""})
    public String index(Model m){
        List<Category> allParent = categoryService.selectAllParent();
        PageInfo<Goods> goodsList = goodsService.selectByLike(null, 1, 8);
        m.addAttribute("allParent",allParent);
        m.addAttribute("goodsList",goodsList);
        return "index";
    }

}
